//
//  YJW_DatePickerView.m
//  YJW掌盟
//
//  Created by dllo on 16/3/2.
//  Copyright © 2016年 dllo. All rights reserved.
//

#import "YJW_DatePickerView.h"
#define WIDTHV self.frame.size.width
#define HEIGHTV self.frame.size.height
@implementation YJW_DatePickerView

- (id)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        [self createView];
    }
    return self;
}

- (void)createView{
    
    self.bigBackView = [[UIView alloc] init];
    self.bigBackView.backgroundColor = COLORBLACK;
//    self.bigBackView.alpha = 0.8;
    [self addSubview:self.bigBackView];
    
    self.backView = [[UIView alloc] init];
    [self.bigBackView addSubview:self.backView];
    self.backView.backgroundColor = [UIColor colorWithRed:26/255.0 green:30/255.0 blue:41/255.0 alpha:1];
    
    self.buttonCancel = [[UIButton alloc] init];
    [self.buttonCancel setTitle:@"取消" forState:0];
    [self.buttonCancel setTitleColor:[UIColor whiteColor] forState:0];
    [self.backView addSubview:self.buttonCancel];
    
    self.buttonSure = [[UIButton alloc] init];
    [self.buttonSure setTitle:@"确定" forState:0];
    [self.buttonSure setTitleColor:[UIColor whiteColor] forState:0];
    [self.backView addSubview:self.buttonSure];
    
    self.datePicker = [[UIDatePicker alloc] init] ;
    _datePicker.datePickerMode = UIDatePickerModeDate;
    [self addSubview:self.datePicker];
    self.dateForMatter = [[NSDateFormatter alloc] init];
    [_dateForMatter setDateFormat:@"yyyy-MM-dd"];
    self.date = [_dateForMatter dateFromString:@"1950-1-1"];
    self.datePicker.minimumDate = self.date;
    [self.datePicker setDate:self.datePicker.date animated:YES];
}

- (void)layoutSubviews{
    self.bigBackView.frame = CGRectMake(0, 0, WIDTHV, HEIGHTV);
    self.backView.frame = CGRectMake(0, HEIGHTV-266, WIDTHV, 50);
    self.buttonCancel.frame = CGRectMake(10, 0, 50, 50);
    self.buttonSure.frame = CGRectMake(WIDTHV-60, 0, 50, 50);
    self.datePicker.frame = CGRectMake(15, HEIGHTV-216, WIDTHV, 216);
}


@end
